// 菜单管理相关的接口
import request from '@/utils/request'
import type { AllPermissionResponseData, MenuParams } from './type'

enum API {
  // 获取所有菜单
  ALLPERMISSION_API = "/admin/acl/permission",
  // 新增菜单
  ADDPERMISSION_API = "/admin/acl/permission/save",
  // 修改菜单
  UPDATEPERMISSION_API = "/admin/acl/permission/update",
  // 删除菜单
  DELETEPERMISSION_API = "/admin/acl/permission/remove/",
}

// 获取所有菜单
export const reqAllPermission = () =>
  request.get<any, AllPermissionResponseData>(API.ALLPERMISSION_API)
// 新增或修改菜单
export const reqAddOrUpdatePermission = (data: MenuParams) => {
  if (data.id) {
    return request.put<any, any>(API.UPDATEPERMISSION_API, data)
  } else {
    return request.post<any, any>(API.ADDPERMISSION_API, data)
  }
}
// 删除菜单
export const reqDeletePermissionById = (id: number) =>
  request.delete<any, any>(API.DELETEPERMISSION_API + id)
